import type { BasicStoreCyberObservable, BasicStoreEntity, StoreEntity } from '../../types/store';
import type { StixDomainObject, StixId } from '../../types/stix-common';

export const ENTITY_TYPE_MALWARE_ANALYSIS = 'Malware-Analysis';
export const INPUT_HOST_VM = 'hostVm';
export const INPUT_OPERATING_SYSTEM = 'operatingSystem';
export const INPUT_INSTALLED_SOFTWARE = 'installedSoftware';
export const INPUT_ANALYSIS_SCO = 'analysisSco';
export const INPUT_SAMPLE = 'analysisSample';

export const ATTRIBUTE_HOST_VM = 'host_vm_ref';
export const RELATION_HOST_VM = 'host-vm';
export const ATTRIBUTE_OPERATING_SYSTEM = 'operating_system_ref';
export const RELATION_OPERATING_SYSTEM = 'operating-system';
export const ATTRIBUTE_INSTALLED_SOFTWARE = 'installed_software_refs';
export const RELATION_INSTALLED_SOFTWARE = 'installed-software';
export const ATTRIBUTE_ANALYSIS_SCO = 'analysis_sco_refs';
export const RELATION_ANALYSIS_SCO = 'analysis-sco';
export const ATTRIBUTE_SAMPLE = 'sample_ref';
export const RELATION_SAMPLE = 'sample';

// region Database types
export interface BasicStoreEntityMalwareAnalysis extends BasicStoreEntity {
  product: string
  version: string
  configuration_version: string
  modules: Array<string>
  analysis_engine_version: string
  analysis_definition_version: string
  submitted: Date
  analysis_started: Date
  analysis_ended: Date
  result_name: string
  result: string
}

export interface StoreEntityMalwareAnalysis extends StoreEntity {
  product: string
  version: string
  [INPUT_HOST_VM]: BasicStoreCyberObservable
  [INPUT_OPERATING_SYSTEM]: BasicStoreCyberObservable
  [INPUT_INSTALLED_SOFTWARE]: Array<BasicStoreCyberObservable>
  configuration_version: string
  modules: Array<string>
  analysis_engine_version: string
  analysis_definition_version: string
  submitted: Date
  analysis_started: Date
  analysis_ended: Date
  result_name: string
  result: string
  [INPUT_ANALYSIS_SCO]: Array<BasicStoreCyberObservable>
  [INPUT_SAMPLE]: BasicStoreCyberObservable
}

export interface StixMalwareAnalysis extends StixDomainObject {
  product: string;
  version: string; // optional
  host_vm_ref: StixId | undefined; // optional
  operating_system_ref: StixId; // optional
  installed_software_refs: Array<StixId>; // optional
  configuration_version: string; // optional
  modules: Array<string>; // optional
  analysis_engine_version: string; // optional
  analysis_definition_version: string; // optional
  submitted: Date; // optional
  analysis_started: Date; // optional
  analysis_ended: Date; // optional
  result_name: string;
  result: string; // malware-result-ov - optional
  analysis_sco_refs: Array<StixId>; // optional
  sample_ref: StixId; // optional
}
// endregion
